package com.joycessh.action.user;

import org.hibernate.HibernateException;

import com.joycessh.VO.user.RegisterVO;
import com.joycessh.service.IUserService;
import com.joycessh.service.impl.UserServiceImpl;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class RegisterAction extends ActionSupport {
	
	private RegisterVO registervo;
	private IUserService userService;
	
	public RegisterVO getRegistervo() {
		return registervo;
	}
	public void setRegistervo(RegisterVO registervo) {
		this.registervo=registervo;
	}
	
	
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		boolean flag = false;
		userService = new UserServiceImpl();
		
		//ActionContext ac = ActionContext.getContext();
		
		
		try {
			flag = userService.userRegister(registervo);
		}catch(HibernateException e) {
			e.printStackTrace();
			return "input";
		}
		
		if(flag) {
			return "success";
		}else {
			return "input";
		}
		
		
	}
	
	
}
